/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fjut.se1603.tata.util;

import edu.fjut.se1603.tata.util.PetStoreService;
import edu.fjut.se1603.tata.util.PetOwnerService;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import jdk.nashorn.internal.parser.TokenType;


/**
 *
 * @author admin
 */
 public class Log_in {
    public int login()
    {
             //提示用户输入密码
             int biaoshi=0;
             Scanner input=new Scanner(System.in); 
             System.out.print("请输入登陆模式，输入1为宠物主人登陆，输入2为宠物商店登陆:");
             int pd = input.nextInt();
             while(pd!=1&&pd!=2)
             {
                 System.out.println("登陆模式错误！");
                 System.out.print("请输入登陆模式，输入1为宠物主人登陆，输入2为宠物商店登陆:");
                 pd = input.nextInt();
             }
             if(pd==1)
             {
                 biaoshi=PetOwnerService.login();
                 if(biaoshi!=0)
                { 
                        System.out.println("登陆成功，你可以购买和卖出宠物，购买宠物请输入1，卖出宠物请输入2");
                    System.out.println("1,购买宠物");
                    System.out.println("2,卖出宠物");
                     int x=input.nextInt();
                     if(x==1)
                    {
                         System.out.println("——————请输入选择要购买的范围：只输入选择项序列号————————");
                         System.out.println("1,购买库存宠物");
                            System.out.println("2,购买新培育宠物"); 
                      }
                     else
                     {
                         biaoshi=-biaoshi;
                     }
                 }
             }
             else
             {
                 biaoshi=PetStoreService.login();
                 if (biaoshi!=0) {
                     System.out.println("登陆成功，你可以购买和卖出宠物，购买宠物请输入1，卖出宠物请输入2");
                 System.out.println("1,购买宠物");
                 System.out.println("2,卖出宠物");
                  int x=input.nextInt();
                      System.out.println("——————请输入选择要购买的范围：只输入选择项序列号————————");
                      System.out.println("1,购买库存宠物");
                         System.out.println("2,购买新培育宠物");
                     
                 }
                  
             }
                 
             
            return  biaoshi;
        }
         
    }
